﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Dukou.Javascript
{
    public class JsExpr
    {
        #region JsComparisonExpr

        public static JsExpr Eq(object left, object right)
        {
            return new JsComparisonExpr(left, right, JsComparisonOperator.Eq);
        }

        public static JsExpr Ne(object left, object right)
        {
            return new JsComparisonExpr(left, right, JsComparisonOperator.Ne);
        }

        public static JsExpr Ge(object left, object right)
        {
            return new JsComparisonExpr(left, right, JsComparisonOperator.Ge);
        }

        public static JsExpr Le(object left, object right)
        {
            return new JsComparisonExpr(left, right, JsComparisonOperator.Le);
        }

        public static JsExpr Gt(object left, object right)
        {
            return new JsComparisonExpr(left, right, JsComparisonOperator.Gt);
        }

        public static JsExpr Lt(object left, object right)
        {
            return new JsComparisonExpr(left, right, JsComparisonOperator.Lt);
        }

        #endregion

        #region JsLogicalExpr

        public static JsExpr And(object left, object right)
        {
            return new JsLogicalExpr(left, right, JsLogicalOperator.And);
        }

        public static JsExpr Or(object left, object right)
        {
            return new JsLogicalExpr(left, right, JsLogicalOperator.Or);
        }

        public static JsExpr Not(object left)
        {
            return new JsLogicalExpr(left);
        }

        #endregion

        #region JsArithmeticExpr

        /// <summary>
        /// 加法
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static JsExpr Plus(object left, object right)
        {
            return new JsArithmeticExpr(left, right, JsArithmeticOperator.Plus);
        }

        /// <summary>
        /// 减法
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static JsExpr Sub(object left, object right)
        {
            return new JsArithmeticExpr(left, right, JsArithmeticOperator.Sub);
        }

        /// <summary>
        /// 取模
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static JsExpr Mod(object left, object right)
        {
            return new JsArithmeticExpr(left, right, JsArithmeticOperator.Mod);
        }

        /// <summary>
        /// 除法
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static JsExpr Div(object left, object right)
        {
            return new JsArithmeticExpr(left, right, JsArithmeticOperator.Div);
        }

        /// <summary>
        /// 乘法
        /// </summary>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <returns></returns>
        public static JsExpr Mul(object left, object right)
        {
            return new JsArithmeticExpr(left, right, JsArithmeticOperator.Mul);
        }

        /// <summary>
        /// 自增
        /// </summary>
        /// <param name="left"></param>
        /// <returns></returns>
        public static JsExpr Inc(object left)
        {
            return new JsArithmeticExpr(left, null, JsArithmeticOperator.Inc);
        }

        /// <summary>
        /// 自减
        /// </summary>
        /// <param name="left"></param>
        /// <returns></returns>
        public static JsExpr Dec(object left)
        {
            return new JsArithmeticExpr(left, null, JsArithmeticOperator.Dec);
        }

        #endregion

    }
}
